home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / ada / gnat1792.zip / gnat179b / t-adainc / a-charac.adb < prev    next >
Text File  |  1994-05-19  |  43KB  |  934 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT RUNTIME COMPONENTS                          --
  4. --                                                                          --
  5. --                       A D A . C H A R A C T E R S                        --
  6. --                                                                          --
  7. --                                 B o d y                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.9 $                              --
  10. --                                                                          --
  11. --           Copyright (c) 1992,1993,1994 NYU, All Rights Reserved          --
  12. --                                                                          --
  13. -- GNAT is free software;  you can  redistribute it  and/or modify it under --
  14. -- terms of the  GNU General Public License as published  by the Free Soft- --
  15. -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
  16. -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
  17. -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  18. -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
  19. -- for  more details.  You should have  received  a copy of the GNU General --
  20. -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
  21. -- to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. --
  22. --                                                                          --
  23. ------------------------------------------------------------------------------
  24.  
  25. with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
  26. with Ada.Strings.Maps;
  27. with Ada.Strings.Constants;
  28.  
  29. package body Ada.Characters is
  30.  
  31.    ------------------------------------
  32.    -- Character Classification Table --
  33.    ------------------------------------
  34.  
  35.    type Character_Flags is mod 256;
  36.    for Character_Flags'Size use 8;
  37.  
  38.    Control    : constant Character_Flags := 1;
  39.    Lower      : constant Character_Flags := 2;
  40.    Upper      : constant Character_Flags := 4;
  41.    Basic      : constant Character_Flags := 8;
  42.    Hex_Digit  : constant Character_Flags := 16;
  43.    Digit      : constant Character_Flags := 32;
  44.    Special    : constant Character_Flags := 64;
  45.  
  46.    Letter     : constant Character_Flags := Lower or Upper;
  47.    Alphanum   : constant Character_Flags := Letter or Digit;
  48.    Graphic    : constant Character_Flags := Alphanum or Special;
  49.  
  50.    Char_Map : constant array (Character) of Character_Flags :=
  51.    (
  52.      NUL                         => Control,
  53.      SOH                         => Control,
  54.      STX                         => Control,
  55.      ETX                         => Control,
  56.      EOT                         => Control,
  57.      ENQ                         => Control,
  58.      ACK                         => Control,
  59.      BEL                         => Control,
  60.      BS                          => Control,
  61.      HT                          => Control,
  62.      LF                          => Control,
  63.      VT                          => Control,
  64.      FF                          => Control,
  65.      CR                          => Control,
  66.      SO                          => Control,
  67.      SI                          => Control,
  68.  
  69.      DLE                         => Control,
  70.      DC1                         => Control,
  71.      DC2                         => Control,
  72.      DC3                         => Control,
  73.      DC4                         => Control,
  74.      NAK                         => Control,
  75.      SYN                         => Control,
  76.      ETB                         => Control,
  77.      CAN                         => Control,
  78.      EM                          => Control,
  79.      SUB                         => Control,
  80.      ESC                         => Control,
  81.      FS                          => Control,
  82.      GS                          => Control,
  83.      RS                          => Control,
  84.      US                          => Control,
  85.  
  86.      Space                       => Special,
  87.      Exclamation                 => Special,
  88.      Quotation                   => Special,
  89.      Number_Sign                 => Special,
  90.      Dollar_Sign                 => Special,
  91.      Percent_Sign                => Special,
  92.      Ampersand                   => Special,
  93.      Apostrophe                  => Special,
  94.      Left_Parenthesis            => Special,
  95.      Right_Parenthesis           => Special,
  96.      Asterisk                    => Special,
  97.      Plus_Sign                   => Special,
  98.      Comma                       => Special,
  99.      Hyphen                      => Special,
  100.      Full_Stop                   => Special,
  101.      Solidus                     => Special,
  102.  
  103.      '0' .. '9'                  => Digit + Hex_Digit,
  104.  
  105.      Colon                       => Special,
  106.      Semicolon                   => Special,
  107.      Less_Than_Sign              => Special,
  108.      Equals_Sign                 => Special,
  109.      Greater_Than_Sign           => Special,
  110.      Question                    => Special,
  111.      Commercial_At               => Special,
  112.  
  113.      'A' .. 'F'                  => Upper + Basic + Hex_Digit,
  114.      'G' .. 'Z'                  => Upper + Basic,
  115.  
  116.      Left_Square_Bracket         => Special,
  117.      Reverse_Solidus             => Special,
  118.      Right_Square_Bracket        => Special,
  119.      Circumflex                  => Special,
  120.      Low_Line                    => Special,
  121.      Grave                       => Special,
  122.  
  123.      'a' .. 'f'                  => Lower + Basic + Hex_Digit,
  124.      'g' .. 'z'                  => Lower + Basic,
  125.  
  126.      Left_Curly_Bracket          => Special,
  127.      Vertical_Line               => Special,
  128.      Right_Curly_Bracket         => Special,
  129.      Tilde                       => Special,
  130.  
  131.      DEL                         => Control,
  132.  
  133.      Reserved_128                => Control,
  134.      Reserved_129                => Control,
  135.      Reserved_130                => Control,
  136.      Reserved_131                => Control,
  137.      IND                         => Control,
  138.      NEL                         => Control,
  139.      SSA                         => Control,
  140.      ESA                         => Control,
  141.      HTS                         => Control,
  142.      HTJ                         => Control,
  143.      VTS                         => Control,
  144.      PLD                         => Control,
  145.      PLU                         => Control,
  146.      RI                          => Control,
  147.      SS2                         => Control,
  148.      SS3                         => Control,
  149.  
  150.      DCS                         => Control,
  151.      PU1                         => Control,
  152.      PU2                         => Control,
  153.      STS                         => Control,
  154.      CCH                         => Control,
  155.      MW                          => Control,
  156.      SPA                         => Control,
  157.      EPA                         => Control,
  158.  
  159.      Reserved_152                => Control,
  160.      Reserved_153                => Control,
  161.      Reserved_154                => Control,
  162.      CSI                         => Control,
  163.      ST                          => Control,
  164.      OSC                         => Control,
  165.      PM                          => Control,
  166.      APC                         => Control,
  167.  
  168.      No_Break_Space              => Special,
  169.      Inverted_Exclamation        => Special,
  170.      Cent_Sign                   => Special,
  171.      Pound_Sign                  => Special,
  172.      Currency_Sign               => Special,
  173.      Yen_Sign                    => Special,
  174.      Broken_Bar                  => Special,
  175.      Section_Sign                => Special,
  176.      Diaeresis                   => Special,
  177.      Copyright_Sign              => Special,
  178.      Feminine_Ordinal_Indicator  => Special,
  179.      Left_Angle_Quotation        => Special,
  180.      Not_Sign                    => Special,
  181.      Soft_Hyphen                 => Special,
  182.      Registered_Trade_Mark_Sign  => Special,
  183.      Macron                      => Special,
  184.      Degree_Sign